<form id="add-applyUser-form" lay-filter="add-applyUser-form" class="layui-form model-form">
    <input name="app_id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">用户</label>
        <div class="layui-input-block">
            <select name="ent_user_id" id="ent_user_id" lay-verify="required"></select>
        </div>
    </div>
    <div class="layui-form-item model-form-footer">
        <button class="layui-btn" lay-filter="applyUser-form-submit" lay-submit style="background: #38B7CB;
">确定
        </button>
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
    </div>
</form>

<script>
    layui.use(['form', 'admin', 'layer',], function () {
        var form = layui.form,
            layer = layui.layer,
            admin = layui.admin;

        // 回显user数据
        var applyUser = admin.getTempData('appData');
        form.val('add-applyUser-form', applyUser);

        var getUserList = function () {
            admin.req('api-sys/api/sysUser/list', {entCode: 'E2E'}, function (data) {
                //给一个默认值（‘请选择’）
                var opt = '<option value="" selected=""></option>';
                //获取返回的数据
                var value = data.data;
                console.log(value,777)
                //循环遍历
                for (var i in value) {
                    opt += '<option value = "' + value[i].user_id + '">' + value[i].username + '</option>'
                }
                $("#ent_user_id").html(opt);
                form.render('select');//需要渲染一下
            }, 'GET');
        }
        getUserList();

        form.on('submit(applyUser-form-submit)', function (data) {
            layer.load(2);
            admin.req('api-sys/api/entUserApp/add', JSON.stringify(data.field), function (data) {
            layer.closeAll('loading');
            if (data.code == 0) {
              layer.msg(data.msg, {icon: 1, time: 500});
              admin.finishPopupCenter();
            } else {
              layer.msg(data.msg, {icon: 2, time: 500});
            }
            }, 'POST');
        });
    })
</script>